﻿using Taobao.Top.Api.Request;
using ProductItem = Taobao.Top.Api.Domain.Item;

namespace Jlvier.TaobaoShowcase.Service
{
    public class ProductItemService : IProductItemService
    {
        public void Recommend(object productItem)
        {
            var item = (ProductItem) productItem;
            var client = RequestClientFactory.Create();
            var request = new ItemRecommendAddRequest { NumIid = item.NumIid };
            client.ItemRecommendAdd(request);
            APIInvokeMonitor.Instance.Delay();
            APIInvokeMonitor.Instance.Count++;
        }

        public void RemoveRecommendation(object productItem)
        {
            var item = (ProductItem)productItem;
            var client = RequestClientFactory.Create();
            var request = new ItemRecommendDeleteRequest { NumIid = item.NumIid };
            client.ItemRecommendDelete(request);
            APIInvokeMonitor.Instance.Delay();
            APIInvokeMonitor.Instance.Count++;
        }
    }
}